﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Synthesis;

namespace Sara
{
    class SpeechSynthesis
    {
        SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();

        Window1 window;

        public SpeechSynthesis(Window1 window)
        {
            speechSynthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
            this.window = window;
        }

        public void read(string text)
        {
            try
            {
                PromptBuilder builder = new PromptBuilder();
                builder.AppendText(text);
                speechSynthesizer.SpeakAsync(builder);
                window.textBlock1.Text = text;
            }
            catch
            {
            }
        }

        public void readWeather(DateTime date)
        {
            read("You want to know how the weather is for " + date.ToShortDateString() 
                + ". Unfortunately, I'm not sure, because you haven't told me how to talk to anyone who can tell me the weather." );
        }

        public void readMeetings(DateTime date)
        {
            read("As far as I can tell, you have no meetings for " + date.ToShortDateString() 
                + ", but I haven't been hooked up to any calendar system yet.");
        }

        public void readAlarmSet(DateTime date)
        {
            read("The alarm has been set for " + date.ToShortTimeString() + ".");
        }

        public void readAlarmActive()
        {
            for (int i = 0; i < 5; i++)
            {
                read("Greg, it's time to get up! It's " + DateTime.Now.ToShortTimeString() + ". . .");
            }
        }

        public void readAlarmUnset()
        {
            read("The alarm has been turned off.");
        }

        public void readSnooze(DateTime time)
        {
            read("Snoozing alarm. I will wake you up in 4 and a half minutes, at " 
                + time.ToShortTimeString() + ".");
        }

        public void stopReading()
        {
            speechSynthesizer.SpeakAsyncCancelAll();
        }

        public void readTime(DateTime time)
        {
            read("It is " + time.ToShortTimeString() + ".");
        }

        public void readYoureWelcome()
        {
            read("You're welcome.");
        }

        public void readGoodnight()
        {
            read("Goodnight.");
        }
    }
}
